<template>
    <div>
        <div class="accounthead">
            <span>搜索限制维护</span>
        </div>

        <div class="bigbox">
            <div class="scrollbox">
                <el-tabs :tab-position="tabPosition" style="height: 200px;">
                <el-tab-pane label="负面舆情">

                    <div class="selectBox">
                        <div>1.发布时间</div>
                         <el-select v-model="nettimevalue" placeholder="请选择" @change="getnetTime">
                            <el-option
                            v-for="item in netime"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                            </el-option>
                        </el-select>
                         <!-- <div class="block">
                            <el-date-picker
                            value-format = "yyyy-MM-dd"
                            @change="changeTime"
                            v-model="nettimes"
                            type="daterange"
                            range-separator="至"
                            start-placeholder="开始日期"
                            end-placeholder="结束日期">
                            </el-date-picker>
                        </div> -->
                    </div>

                    <div class="selectBox">
                        <div>2.百度页数（10条/页）</div>
                         <el-select v-model="netpagevalue" placeholder="请选择" @change="getnenetpage">
                            <el-option
                            v-for="item in netpage"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                            </el-option>
                        </el-select>
                    </div>

                    <div class="selectBox">
                        <div>3.关键词出现位置</div>
                         <el-select v-model="netplacevalue" placeholder="请选择" @change="getnenetplace">
                            <el-option
                            v-for="item in netplace"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                            </el-option>
                        </el-select>
                    </div>

                    <!-- <div class="selectBox">
                        <div>4.不相关性设置</div>
                         <el-select v-model="netEffevalue" placeholder="请选择" @change="getneEffe">
                            <el-option
                            v-for="item in netEffe"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                            </el-option>
                        </el-select>
                    </div> -->

                    <div class="selectBox">
                        <div>4.自定义阈值去重（%）</div>
                         <el-input-number :controls="false" :min="1" :max="100" :precision="0" @blur="threshold" v-model="thresholdvalue"></el-input-number>
                    </div>

                    <div class="selectBox">
                        <div>5.黑名单网址</div>
                        <div class="urlActive">请注意：若想添加某域名及其子域名进入黑名单，请以*号输入，如”*.baidu.com"。</div>
                        <svg class="penSvn penico penurl" version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
                            viewBox="0 0 20 20" style="enable-background:new 0 0 20 20;" xml:space="preserve" @click="openUpdateUrl">
                        <rect x="-354.3" y="-271.1" class="st0" width="20" height="20"/>
                        <polygon class="st1" points="1.7,18.5 2.5,14.8 5.3,17.6 "/>
                        <g>
                            <path class="st1" d="M18.5,4.3l1-1c0.2-0.2,0.2-0.5,0-0.7l-2.1-2.1c-0.2-0.2-0.5-0.2-0.7,0l-1,1L18.5,4.3z"/>
                            <rect x="1.7" y="7.6" transform="matrix(0.7071 -0.7071 0.7071 0.7071 -3.6929 10.2382)" class="st1" width="17.7" height="3.9"/>
                        </g>
                        </svg>

                         <input type="text" class="bottomborder" v-model="blackUrl" onfocus="this.blur()" @click="openUpdateUrl">
                    </div>

                    <div class="selectBox">
                        <div>6.黑名单内容</div>

                        <svg class="penSvn penico" version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
                            viewBox="0 0 20 20" style="enable-background:new 0 0 20 20;" xml:space="preserve"  @click="blackconFormVisible = true">
                        <rect x="-354.3" y="-271.1" class="st0" width="20" height="20"/>
                        <polygon class="st1" points="1.7,18.5 2.5,14.8 5.3,17.6 "/>
                        <g>
                            <path class="st1" d="M18.5,4.3l1-1c0.2-0.2,0.2-0.5,0-0.7l-2.1-2.1c-0.2-0.2-0.5-0.2-0.7,0l-1,1L18.5,4.3z"/>
                            <rect x="1.7" y="7.6" transform="matrix(0.7071 -0.7071 0.7071 0.7071 -3.6929 10.2382)" class="st1" width="17.7" height="3.9"/>
                        </g>
                        </svg>

                         <input type="text" class="bottomborder" v-model="blackWord" onfocus="this.blur()" @click="blackconFormVisible = true">
                    </div>
                   
                </el-tab-pane>


                <el-tab-pane label="五大模块">
                    <div class="selectBox">
                        <div>1.发布时间</div>
                         <!-- <el-select v-model="fiveTimevalue" placeholder="请选择" @change="getfiveTime">
                            <el-option
                            v-for="item in fiveTime"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                            </el-option>
                        </el-select> -->
                        <div class="block">
                            <el-date-picker
                            value-format = "yyyy-MM-dd"
                            @change="changefiveTime"
                            v-model="fivetimes"
                            type="daterange"
                            range-separator="至"
                            start-placeholder="开始日期"
                            end-placeholder="结束日期">
                            </el-date-picker>
                        </div>
                    </div>

                    <div class="selectBox">
                        <div>2.百度页数（10条/页）</div>
                         <el-select v-model="fivepagevalue" placeholder="请选择" @change="setfivepage">
                            <el-option
                            v-for="item in fivepage"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                            </el-option>
                        </el-select>
                    </div>

                    <div class="selectBox">
                        <div>3.关键词出现位置</div>
                         <el-select v-model="fiveplacevalue" placeholder="请选择" @change="setfiveplace">
                            <el-option
                            v-for="item in fiveplace"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                            </el-option>
                        </el-select>
                    </div>

                    <!-- <div class="selectBox" style="display: none;">
                        <div>4.不相关性设置</div>
                         <el-select v-model="fiveEffevalue" placeholder="请选择" @change="setfiveEffe">
                            <el-option
                            v-for="item in fiveEffe"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                            </el-option>
                        </el-select>
                    </div> -->

                     <div class="selectBox">
                        <div>4.自定义阈值去重（%）</div>
                         <el-input-number :controls="false" :min="1" :max="100" :precision="0" @blur="fivethreshold" v-model="fivethresholdvalue"></el-input-number>
                    </div>

                    <div class="selectBox">
                        <div>5.黑名单网址</div>
                        <div class="urlActive">请注意：若想添加某域名及其子域名进入黑名单，请以*号输入，如”*.baidu.com"。</div>
                        <svg class="penSvn penico penurl" version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
                            viewBox="0 0 20 20" style="enable-background:new 0 0 20 20;" xml:space="preserve"  @click="fiveupdateFormVisible = true">
                        <rect x="-354.3" y="-271.1" class="st0" width="20" height="20"/>
                        <polygon class="st1" points="1.7,18.5 2.5,14.8 5.3,17.6 "/>
                        <g>
                            <path class="st1" d="M18.5,4.3l1-1c0.2-0.2,0.2-0.5,0-0.7l-2.1-2.1c-0.2-0.2-0.5-0.2-0.7,0l-1,1L18.5,4.3z"/>
                            <rect x="1.7" y="7.6" transform="matrix(0.7071 -0.7071 0.7071 0.7071 -3.6929 10.2382)" class="st1" width="17.7" height="3.9"/>
                        </g>
                        </svg>
                         <input type="text" v-model="fiveblackUrl" class="bottomborder" onfocus="this.blur()" @click="fiveupdateFormVisible = true">
                    </div>

                    <div class="selectBox">
                        <div>6.黑名单内容</div>
                        <svg class="penSvn penico" version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
                            viewBox="0 0 20 20" style="enable-background:new 0 0 20 20;" xml:space="preserve" @click="fiveblackconFormVisible = true">
                        <rect x="-354.3" y="-271.1" class="st0" width="20" height="20"/>
                        <polygon class="st1" points="1.7,18.5 2.5,14.8 5.3,17.6 "/>
                        <g>
                            <path class="st1" d="M18.5,4.3l1-1c0.2-0.2,0.2-0.5,0-0.7l-2.1-2.1c-0.2-0.2-0.5-0.2-0.7,0l-1,1L18.5,4.3z"/>
                            <rect x="1.7" y="7.6" transform="matrix(0.7071 -0.7071 0.7071 0.7071 -3.6929 10.2382)" class="st1" width="17.7" height="3.9"/>
                        </g>
                        </svg>
                         <input type="text" v-model="fiveblackWord" class="bottomborder" onfocus="this.blur()" @click="fiveblackconFormVisible = true">
                    </div>

                    <div class="selectBox">
                        <div>7.宏观经济有效期(最近天数)</div>
                         <!-- <el-select v-model="honetimevalue" placeholder="请选择" @change="setHongTime">
                            <el-option
                            v-for="item in honetime"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                            </el-option>
                        </el-select> -->
                        <el-input-number :controls="false" :min="7" :max="3650" :precision="0" @blur="setHongTime" v-model="honetimevalue"></el-input-number>
                    </div>

                     <div class="selectBox">
                        <div>8.行业信息有效期(最近天数)</div>
                         <!-- <el-select v-model="hanetimevalue" placeholder="请选择" @change="setHangTime">
                            <el-option
                            v-for="item in hanetime"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                            </el-option>
                        </el-select> -->
                        <el-input-number :controls="false" :min="7" :max="3650" :precision="0" @blur="setHangTime" v-model="hanetimevalue"></el-input-number>
                    </div>

                     <div class="selectBox">
                        <div>9.监管环境有效期(最近天数)</div>
                         <!-- <el-select v-model="jiantimevalue" placeholder="请选择" @change="setJianTime">
                            <el-option
                            v-for="item in jiantime"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                            </el-option>
                        </el-select> -->
                        <el-input-number :controls="false" :min="7" :max="3650" :precision="0" @blur="setJianTime" v-model="jiantimevalue"></el-input-number>
                    </div>

                     <div class="selectBox baidubox">
                        <div>10.公司新闻搜索范围(最近天数)</div>
                         <el-select v-model="scopevalue" placeholder="请选择" @change="setScope">
                            <el-option
                            v-for="item in scope"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                            </el-option>
                        </el-select>
                        <!-- <el-input-number :controls="false" :min="7" :max="3650" :precision="0" @blur="setScope" v-model="scopevalue"></el-input-number> -->
                    </div>
                </el-tab-pane>
            </el-tabs>
            </div>
        </div>

         <el-dialog title="编辑黑名单网址" :visible.sync="updateFormVisible">
            <el-form>

                <div class="moudlecon">
                <!-- <div class="text1">黑名单网址模板</div> -->
                <div class="text2">请输入黑名单网址（一行一个）</div>
                <div class="urlActive">请注意：若想添加某域名及其子域名进入黑名单，请以*号输入，如”*.baidu.com"。</div>
                <!-- <textarea v-html="mStr2" id="Strtext" @change="changeText"></textarea> -->
                <textarea class="textareaUrl" ref="fmUrltext" v-html="blackArea" @change="changeText"></textarea>
                </div>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="updateFormVisible = false">取 消</el-button>
                <el-button type="danger" @click="UpdateblackUrl">保 存</el-button>
            </div>
        </el-dialog>

        <el-dialog title="编辑黑名单网址" :visible.sync="fiveupdateFormVisible">
            <el-form>

                <div class="moudlecon">
                <!-- <div class="text1">黑名单网址模板</div> -->
                <div class="text2">请输入黑名单网址（一行一个）</div>
                <div class="urlActive">请注意：若想添加某域名及其子域名进入黑名单，请以*号输入，如”*.baidu.com"。</div>
                <!-- <textarea v-html="mStr2" id="Strtext" @change="changeText"></textarea> -->
                <textarea class="textareaUrl" id="Strtext" v-html="fiveblackArea" @change="fivechangeText"></textarea>
                </div>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="fiveupdateFormVisible = false">取 消</el-button>
                <el-button type="danger" @click="fiveUpdateblackUrl">保 存</el-button>
                <!-- @click="fiveUpdateblackUrl" -->
            </div>
        </el-dialog>

         <el-dialog title="编辑黑名单内容" :visible.sync="blackconFormVisible">
            <el-form>
                <div class="moudlecon">
                <!-- <div class="text1">黑名单内容</div> -->
                <div class="text2">请输入黑名单内容（一行一个）</div>
                <!-- <textarea v-html="mStr2" id="Strtext" @change="changeText"></textarea> -->
                <textarea id="Strtext" v-html="blackconTextarea" @change="changeText2"></textarea>
                </div>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="blackconFormVisible = false">取 消</el-button>
                <el-button type="danger" @click="UpdateblackCon">保 存</el-button>
            </div>
        </el-dialog>

         <el-dialog title="编辑黑名单内容" :visible.sync="fiveblackconFormVisible">
            <el-form>
                <div class="moudlecon">
                <!-- <div class="text1">黑名单内容</div> -->
                <div class="text2">请输入黑名单内容（一行一个）</div>
                <!-- <textarea v-html="mStr2" id="Strtext" @change="changeText"></textarea> -->
                <textarea id="Strtext" v-html="fiveblackconTextarea" @change="fivechangeText2"></textarea>
                </div>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="fiveblackconFormVisible = false">取 消</el-button>
                <el-button type="danger" @click="fiveUpdateblackCon">保 存</el-button>
                 <!-- @click="UpdateblackCon" -->
            </div>
        </el-dialog>

    </div>
</template>

<script>
import {getModuleInsert1, changeModule,changeModule2,addKeywords, getModuleInsert2, getFiveModuleList} from '@/api'
export default {
    data () {
        return {
            updateFormVisible: false,
            blackconFormVisible: false,
            fiveupdateFormVisible: false,
            fiveblackconFormVisible: false,
            tabPosition: 'top',
            nettimes: ["1970-01-01", "1970-02-12"],
            fivetimes: ["1970-01-01", "1970-02-12"],
            nettimevalue: '',
            netime: [  // 负面舆情的页数
                {
                value: '最近七天',
                label: '最近七天'
                },
                {
                value: '最近一个月',
                label: '最近一个月'
                },{
                value: '最近一年',
                label: '最近一年'
                },{
                 value: '最近两年',
                label: '最近两年'
                },{
                 value: '全部时间',
                label: '全部时间'
                }],
                fiveTimevalue: '',
                fiveTime: [  // 负面舆情的页数
                {
                value: '最近七天',
                label: '最近七天'
                },
                {
                value: '最近一个月',
                label: '最近一个月'
                },{
                value: '最近一年',
                label: '最近一年'
                },{
                 value: '最近两年',
                label: '最近两年'
                },{
                 value: '全部时间',
                label: '全部时间'
                }],
            netpage: [  // 负面舆情的页数
                {
                value: '前十页',
                label: '前十页'
                },
                {
                value: '前二十页',
                label: '前二十页'
                }],
            netpagevalue: '',
            fivepage: [  // 五大模块的页数
                {
                value: '前十页',
                label: '前十页'
                },
                {
                value: '前二十页',
                label: '前二十页'
                }],
            fivepagevalue: '',
             netplace: [  // 负面舆情的关键词出现位置
                {
                value: '任何地方',
                label: '任何地方'
                },
                {
                value: '除url外的任何地方',
                label: '除url外的任何地方'
                },],
            netplacevalue: '',
            fiveplace: [  // 负面舆情的关键词出现位置
                {
                value: '任何地方',
                label: '任何地方'
                },
                {
                value: '除url外的任何地方',
                label: '除url外的任何地方'
                },
               ],
            fiveplacevalue: '',
             netEffe: [  // 负面舆情的不相关性设置
                {
                value: '正文',
                label: '正文'
                },
                {
                value: '标题',
                label: '标题'
                },
                {
                value: '正文+标题',
                label: '正文+标题'
                }],
            netEffevalue: '',
             fiveEffe: [  // 负面舆情的不相关性设置
                {
                value: '正文',
                label: '正文'
                },
                {
                value: '标题',
                label: '标题'
                },
                {
                value: '正文+标题',
                label: '正文+标题'
                }],
            fiveEffevalue: '',
            blackUrl: '',  // 黑名单网址
            blackArea: '', // 黑名单网址文本框的渲染
            fiveblackUrl: '',  // 五大模块黑名单网址
            fiveblackArea: '', // 五大模块黑名单网址文本框的渲染
            blackWord: '', // 黑名单内容
            blackconTextarea: '',
            fiveblackWord: '', // 五大模块黑名单内容
            fiveblackconTextarea: '',
            honetime: [
                 {
                value: '最近七天',
                label: '最近七天'
                },
                {
                value: '最近一个月',
                label: '最近一个月'
                },
                {
                value: '最近一年',
                label: '最近一年'
                },
            ],
            honetimevalue: '',
            hanetime: [
                 {
                value: '最近七天',
                label: '最近七天'
                },
                {
                value: '最近一个月',
                label: '最近一个月'
                },
                {
                value: '最近一年',
                label: '最近一年'
                },
            ],
            hanetimevalue: '',
            jiantime: [
                 {
                value: '最近七天',
                label: '最近七天'
                },
                {
                value: '最近一个月',
                label: '最近一个月'
                },
                {
                value: '最近一年',
                label: '最近一年'
                },
            ],
            jiantimevalue: '',
            scope:[
                 {
                value: '全百度',
                label: '全百度'
                },
                {
                value: '仅限制百度新闻',
                label: '仅限制百度新闻'
                }
            ],
            scopevalue: '',
             options: [
            {
            value: '选项1',
            label: '黄金糕'
            }, {
            value: '选项2',
            label: '双皮奶'
            }, {
            value: '选项3',
            label: '蚵仔煎'
            }, {
            value: '选项4',
            label: '龙须面'
            }, {
            value: '选项5',
            label: '北京烤鸭'
            }],
            value: '',
            thresholdvalue: 1,
            fivethresholdvalue: 1
            }
    },
    created () {
      this.initSafeguard()  
    },
    mounted () {
         this.getTextaarea()
    },
    methods: {
        fivethreshold() {
            if(this.fivethresholdvalue == undefined ) {
                this.fivethresholdvalue = 1
            }
             let thresholdnum = ( this.fivethresholdvalue ) /100
            let obj = {
                threshold: thresholdnum
            }
            changeModule2(obj)
            .then(res => {
                // console.log(res)
            })
        },
        threshold() {
            if(this.thresholdvalue == undefined ) {
                this.thresholdvalue = 1
            }
             let thresholdnum = ( this.thresholdvalue ) /100
            let obj = {
                threshold: thresholdnum
            }
            changeModule(obj)
            .then(res => {
                // console.log(res)
            })
        },
        getfiveTime() {
            console.log(this.fiveTimevalue)
            let obj = null
             if( this.fiveTimevalue == '最近七天') {
                    obj = {
                        time: 7
                    }
                } else if(this.fiveTimevalue == '最近一个月') {
                    obj = {
                        time: 30
                    }
                } else if(this.fiveTimevalue == '最近一年') {
                    obj = {
                        time: 365
                    }
                } else if(this.fiveTimevalue == '全部时间') {
                    obj = {
                        time: 0
                    }
                } else if(this.fiveTimevalue == '最近两年') {
                    obj = {
                        time: 730
                    }
                }
                // console.log(obj) 
            changeModule2(obj)
            .then(res => {
                // console.log(res)
            })
        },
        getnetTime() {
            // console.log(this.nettimevalue)
            let obj = null
             if( this.nettimevalue == '最近七天') {
                    obj = {
                        time: 7
                    }
                } else if(this.nettimevalue == '最近一个月') {
                    obj = {
                        time: 30
                    }
                } else if(this.nettimevalue == '最近一年') {
                    obj = {
                        time: 365
                    }
                } else if(this.nettimevalue == '全部时间') {
                    obj = {
                        time: 0
                    }
                } else if(this.nettimevalue == '最近两年') {
                    obj = {
                        time: 730
                    }
                }
                // console.log(obj)
            changeModule(obj)
            .then(res => {
                console.log(res)
            })
        },
        getTextaarea() {
             const fmUrltext = this.$refs;
            // let fmUrltext = document.getElementsByTagName('textarea')
             console.log(fmUrltext)
        },
        setScope() {
             let obj = null
             if( this.scopevalue == '全百度') {
                    obj = {
                        newsScope: 0
                    }
                } else if(this.scopevalue == '仅限制百度新闻') {
                    obj = {
                        newsScope: 1
                    }
                }
            changeModule2(obj)
            .then(res => {
                // console.log(res)
            })
        },
        setJianTime() {
            // let obj = null
            //  if( this.jiantimevalue == '最近七天') {
            //         obj = {
            //             jianEffe: 7
            //         }
            //     } else if(this.jiantimevalue == '最近一个月') {
            //         obj = {
            //             jianEffe: 30
            //         }
            //     } else if(this.jiantimevalue == '最近一年') {
            //         obj = {
            //             jianEffe: 365
            //         }
            //     }
                // console.log(obj)
            if(this.jiantimevalue == undefined) {
                this.hanetjiantimevalueimevalue = 7
            }
            let obj = {
                jianEffe: this.jiantimevalue
            }
            changeModule2(obj)
            .then(res => {
                // console.log(res)
            })
        },
        // 修改行业信息默认时间
        setHangTime() {
            //  let obj = null
            //  if( this.hanetimevalue == '最近七天') {
            //         obj = {
            //             hangEffe: 7
            //         }
            //     } else if(this.hanetimevalue == '最近一个月') {
            //         obj = {
            //             hangEffe: 30
            //         }
            //     } else if(this.hanetimevalue == '最近一年') {
            //         obj = {
            //             hangEffe: 365
            //         }
            //     }
                // console.log(obj)
                if(this.hanetimevalue == undefined) {
                this.hanetimevalue = 7
            }
                    let obj = {
                        hangEffe: this.hanetimevalue
                    }
            changeModule2(obj)
            .then(res => {
                // console.log(res)
            })
        },
        // 修改宏观默认时间
        setHongTime() {
            //  let obj = null
            //  if( this.honetimevalue == '最近七天') {
            //         obj = {
            //             hongEffe: 7
            //         }
            //     } else if(this.honetimevalue == '最近一个月') {
            //         obj = {
            //             hongEffe: 30
            //         }
            //     } else if(this.honetimevalue == '最近一年') {
            //         obj = {
            //             hongEffe: 365
            //         }
            //     }
            if(this.honetimevalue == undefined) {
                this.honetimevalue = 7
            }
                    let obj = {
                        hongEffe: this.honetimevalue
                    }
                // console.log(obj)
            changeModule2(obj)
            .then(res => {
                // console.log(res)
            })
        },
        // 修改五大模块黑名单内容
        fiveUpdateblackCon() {
             let blackCon = (this.fiveblackconTextarea.trim().split(/\n+/)).join('+')
             blackCon = blackCon.replace(/&#10;/g,'+')
              let obj = null
             if(blackCon=="") {
                    obj = {
                    blackWords: "null"
                }
                } else {
                    obj = {
                         blackWords: blackCon
                    }
                }
            //  let obj = {
            //      blackWords: blackCon
            //  }
            //  console.log(obj)
            changeModule2(obj)
            .then(res => {
                // console.log(res)
                if(res.statusCode ==200) {
                    this.$message({
                        message: res.statusMsg,
                        type: 'success'
                        });
                        this.initSafeguard()
                     this.fiveblackconFormVisible = false
                } else {
                     this.$message({
                        message: res.statusMsg,
                        type: 'error'
                        });
                     this.fiveblackconFormVisible = false
                }
               
            })
        },
        // 修改五大模块黑名单网址
        fiveUpdateblackUrl() {
             let blackUrl = (this.fiveblackArea.trim().split(/\n+/)).join('+')
            //  console.log(blackUrl)
             blackUrl = blackUrl.replace(/&#10;/g,'+')
             
               let blackUrlStr = blackUrl.replace(/\+/g, "")
            //  console.log(blackUrlStr)
            // if(blackUrlStr.length > 1250) {
            //     this.$message({
            //         message: '黑名单字符数超出限制',
            //         type: 'warning'
            //     });
            //     return false
            // }

            let blackUrlArr = blackUrl.replace(/\+/g, '_')
            blackUrlArr = blackUrlArr.split('_')
            if(blackUrlArr.length >300) {
                this.$message({
                    message: '黑名单不能超过300个',
                    type: 'warning'
                });
                return false
            }
             let obj = null
             if(blackUrl=="") {
                    obj = {
                    blackUrl: "null"
                }
                } else {
                    obj = {
                        blackUrl: blackUrl
                    }
                }

            //  let obj = {
            //      blackUrl: blackUrl
            //  }
             console.log(obj)
            changeModule2(obj)
            .then(res => {
                // console.log(res)
                if(res.statusCode ==200) {
                    this.$message({
                        message: res.statusMsg,
                        type: 'success'
                        });
                        this.initSafeguard()
                     this.fiveupdateFormVisible = false
                } else {
                     this.$message({
                        message: res.statusMsg,
                        type: 'error'
                        });
                     this.fiveupdateFormVisible = false
                }
            })
        },
        setfiveEffe() {
            // ckj 修改五大模板不相关性
             let obj = null
             if( this.fiveEffevalue == '正文+标题') {
                    obj = {
                        noEffe: 0
                    }
                } else if(this.fiveEffevalue == '正文') {
                    obj = {
                        noEffe: 1
                    }
                } else if(this.fiveEffevalue == '标题') {
                    obj = {
                        noEffe: 2
                    }
                }
                // console.log(obj)
            changeModule2(obj)
            .then(res => {
                // console.log(res)
            })
        },
        // ckj 修改五大模块页数
        setfivepage() {
            let obj = null
             if( this.fivepagevalue == '前十页') {
                    obj = {
                        pn: 10
                    }
                } else if(this.fivepagevalue == '前二十页') {
                    obj = {
                        pn: 20
                    }
                }

                // console.log(obj)
            changeModule2(obj)
            .then(res => {
                // console.log(res)
            })
        },
        // 修改五大模块关键词位置
        setfiveplace() {
            let obj = null
             if( this.fiveplacevalue == '任何地方') {
                    obj = {
                        keyPlace: 0
                    }
                } else if(this.fiveplacevalue == '除url外的任何地方') {
                    obj = {
                        keyPlace: 1
                    }
                } else if(this.fiveplacevalue == 'url') {
                    obj = {
                        keyPlace: 2
                    }
                }

                // console.log(obj)
            changeModule2(obj)
            .then(res => {
                // console.log(res)
            })
        },
        changeTime() {
             let nettimes = this.nettimes.join('+')
             let obj = {
                 time: nettimes
             }
              changeModule(obj)
            .then(res => {
                // console.log(res)
                if(res.statusCode ==200) {
                    this.$message({
                        message: res.statusMsg,
                        type: 'success'
                        });
                        this.initSafeguard()
                     this.updateFormVisible = false
                } else {
                     this.$message({
                        message: res.statusMsg,
                        type: 'error'
                        });
                     this.updateFormVisible = false
                }
               
            })
        },

        changefiveTime() {
             let nettimes = this.fivetimes.join('+')
             let obj = {
                 time: nettimes
             }
            //  console.log(obj)
              changeModule2(obj)
            .then(res => {
                // console.log(res)
                if(res.statusCode ==200) {
                    this.$message({
                        message: res.statusMsg,
                        type: 'success'
                        });
                        this.initSafeguard()
                     this.updateFormVisible = false
                } else {
                     this.$message({
                        message: res.statusMsg,
                        type: 'error'
                        });
                     this.updateFormVisible = false
                }
               
            })
        },

        openUpdateUrl() {
            this.updateFormVisible = true
        },
        // ckj 点击确定编辑黑名单网址  blackconTextarea
        UpdateblackUrl() {
             let blackUrl = (this.blackArea.trim().split(/\n+/)).join('+')
             blackUrl = blackUrl.replace(/&#10;/g,'+')

             let blackUrlStr = blackUrl.replace(/\+/g, "")
            //  console.log(blackUrlStr)
            // if(blackUrlStr.length > 1250) {
            //     this.$message({
            //         message: '黑名单字符数超出限制',
            //         type: 'warning'
            //     });
            //     return false
            // }
             let blackUrlArr = blackUrl.replace(/\+/g, '_')
             blackUrlArr = blackUrlArr.split('_')
            //  console.log(blackUrlArr.length)
            if(blackUrlArr.length >300) {
                this.$message({
                    message: '黑名单不能超过300个',
                    type: 'warning'
                });
                return false
            }
             let obj = null
                if(blackUrl=="") {
                    obj = {
                    blackUrl: "null"
                }
                } else {
                    obj = {
                        blackUrl: blackUrl
                    }
                }
                // console.log(obj)
             
            //  console.log(obj)
            changeModule(obj)
            .then(res => {
                // console.log(res)
                if(res.statusCode ==200) {
                    this.$message({
                        message: res.statusMsg,
                        type: 'success'
                        });
                        this.initSafeguard()
                     this.updateFormVisible = false
                } else {
                     this.$message({
                        message: res.statusMsg,
                        type: 'error'
                        });
                     this.updateFormVisible = false
                }
               
            })
        },
         UpdateblackCon() {
             let blackCon = (this.blackconTextarea.trim().split(/\n+/)).join('+')
             blackCon = blackCon.replace(/&#10;/g,'+')
             let obj = null
                if(blackCon=="") {
                    obj = {
                    blackWords: "null"
                }
                } else {
                    obj = {
                        blackWords: blackCon
                    }
                }
            //  let obj = {
            //      blackWords: blackCon
            //  }
            //  console.log(obj)
            changeModule(obj)
            .then(res => {
                // console.log(res)
                if(res.statusCode ==200) {
                    this.$message({
                        message: res.statusMsg,
                        type: 'success'
                        });
                        this.initSafeguard()
                     this.blackconFormVisible = false
                } else {
                     this.$message({
                        message: res.statusMsg,
                        type: 'error'
                        });
                     this.blackconFormVisible = false
                }
               
            })
        },
         changeText(e) {
         // console.log(e)  blackconTextarea
         this.blackArea = e.target.value
        //  let shuzuTextarea = this.blackArea.replace(/\n/g, '_')
        //  shuzuTextarea = shuzuTextarea.split('_') 
        //  console.log(shuzuTextarea.length)
        //  if(shuzuTextarea.length > 3) {
        //      console.log('大于')
        //      return false
        //      console.log(456)
        //  }
      },
      fivechangeText(e) {
          this.fiveblackArea = e.target.value
      },
       changeText2(e) {
         // console.log(e)  blackconTextarea
         this.blackconTextarea = e.target.value 
      },
       fivechangeText2(e) {
         // console.log(e)  blackconTextarea
         this.fiveblackconTextarea = e.target.value 
      },
        getnenetpage() {
             let obj = null
             if( this.netpagevalue == '前十页') {
                    obj = {
                        pn: 10
                    }
                } else if(this.netpagevalue == '前二十页') {
                    obj = {
                        pn: 20
                    }
                }

                // console.log(obj)
            changeModule(obj)
            .then(res => {
                // console.log(res)
            })
        },
        getnenetplace() {
            let obj = null
             if( this.netplacevalue == '任何地方') {
                    obj = {
                        keyPlace: 0
                    }
                } else if(this.netplacevalue == '除url外的任何地方') {
                    obj = {
                        keyPlace: 1
                    }
                } else if(this.netplacevalue == 'url') {
                    obj = {
                        keyPlace: 2
                    }
                }

                // console.log(obj)
            changeModule(obj)
            .then(res => {
                // console.log(res)
            })
        },
        // ckj 改变不相关性
        getneEffe() {
               let obj = null
             if( this.netEffevalue == '正文+标题') {
                    obj = {
                        noEffe: 0
                    }
                } else if(this.netEffevalue == '正文') {
                    obj = {
                        noEffe: 1
                    }
                } else if(this.netEffevalue == '标题') {
                    obj = {
                        noEffe: 2
                    }
                }
                // console.log(obj)
            changeModule(obj)
            .then(res => {
                // console.log(res)
            })
        },
        initSafeguard() {
            getModuleInsert1()
            .then(res => {
                // console.log(res)
                // 时间的获取
                // console.log(res.data.time)
                if(res.data.time == '365') {
                    this.nettimevalue = '最近一年'
                } else if(res.data.time == '30') {
                    this.nettimevalue = '最近一个月'
                } else if(res.data.time == '7') {
                    this.nettimevalue = '最近七天'
                }  else if(res.data.time == '0') {
                    this.nettimevalue = '全部时间'
                } else if(res.data.time == '730') {
                    this.nettimevalue = '最近两年'
                }

                // 页数的获取
                if(res.data.pn == '10') {
                    this.netpagevalue = '前十页'
                } else if(res.data.pn == '20') {
                    this.netpagevalue = '前二十页'
                }

                // 关键词出现位置的获取
                if(res.data.keyPlace == '0') {
                    this.netplacevalue = '任何地方'
                } else if(res.data.keyPlace == '1') {
                    this.netplacevalue = '除url外的任何地方'
                }

                // 关键词不相关性的获取
                if(res.data.noEffe == '0') {
                    this.netEffevalue = '正文+标题'
                } else if(res.data.noEffe == '1') {
                    this.netEffevalue = '正文'
                } else if(res.data.noEffe == '2') {
                    this.netEffevalue = '标题'
                }

                // 获取黑名单网址
                let subjectText = res.data.blackUrl
                let sub = subjectText.replace(/\+/g, "/")
                this.blackUrl = sub
                this.blackArea = sub.replace(/\//g,'&#10;')

                // 获取黑名单内容
                let blackWordText = res.data.blackWords
                blackWordText = blackWordText.replace(/\+/g,'/')
                this.blackconTextarea = blackWordText.replace(/\//g,'&#10;')
                this.blackWord = blackWordText

                // 时间间距的获取
                let nettimes = res.data.time
                this.nettimes = nettimes.split('+')
                // console.log(nettimes)

                // 阈值的获取threshold
                this.thresholdvalue = (res.data.threshold)*100
            })
            getModuleInsert2()
            .then(res => {
                // console.log(res.data[0].time.split('+'))
                // this.fivetimes = res.data[0].time.split('+')
                // if(res.data[0].time == '365') {
                //     this.fiveTimevalue = '最近一年'
                // } else if(res.data[0].time == '30') {
                //     this.fiveTimevalue = '最近一个月'
                // } else if(res.data[0].time == '7') {
                //     this.fiveTimevalue = '最近七天'
                // } else if(res.data[0].time == '0') {
                //     this.fiveTimevalue = '全部时间'
                // } else if(res.data[0].time == '730') {
                //     this.fiveTimevalue = '最近两年'
                // }

                // console.log(res)
                 if(res.data[0].pn == '10') {
                    this.fivepagevalue = '前十页'
                } else if(res.data[0].pn == '20') {
                    this.fivepagevalue = '前二十页'
                }

                // 关键词出现位置的获取
                if(res.data[0].keyPlace == '0') {
                    this.fiveplacevalue = '任何地方'
                } else if(res.data[0].keyPlace == '1') {
                    this.fiveplacevalue = '除url外的任何地方'
                } else if(res.data[0].keyPlace == '2') {
                    this.fiveplacevalue = 'url'
                }

                 // 关键词不相关性的获取
                if(res.data[0].noEffe == '0') {
                    this.fiveEffevalue = '正文+标题'
                } else if(res.data[0].noEffe == '1') {
                    this.fiveEffevalue = '正文'
                } else if(res.data[0].noEffe == '2') {
                    this.fiveEffevalue = '标题'
                }

                // 获取黑名单网址
                let subjectText = res.data[0].blackUrl
                let sub = subjectText.replace(/\+/g, "/")
                // console.log(sub)
                this.fiveblackUrl = sub
                this.fiveblackArea = sub.replace(/\//g,'&#10;')

                // 获取黑名单内容
                let blackWordText = res.data[0].blackWords
                blackWordText = blackWordText.replace(/\+/g,'/')
                this.fiveblackconTextarea = blackWordText.replace(/\//g,'&#10;')
                this.fiveblackWord = blackWordText

                // 时间间距的获取
                let fivetimes = res.data[0].time
                this.fivetimes = fivetimes.split('+')
                // console.log(this.fivetimes)

                this.fivethresholdvalue = (res.data[0].threshold)*100
            })

            getFiveModuleList()
            .then(res => {
                // console.log(res)
                this.honetimevalue = res.data.hongEffe
                 this.hanetimevalue = res.data.hangEffe
                  this.jiantimevalue = res.data.jianEffe
                // if(res.data.hongEffe == '365') {
                //     this.honetimevalue = '最近一年'
                // } else if(res.data.hongEffe == '30') {
                //     this.honetimevalue = '最近一个月'
                // } else if(res.data.hongEffe == '7') {
                //     this.honetimevalue = '最近七天'
                // } else if(res.data[0].time == '0') {
                //     this.fiveTimevalue = '全部时间'
                // }

                // if(res.data.hangEffe == '365') {
                //     this.hanetimevalue = '最近一年'
                // } else if(res.data.hangEffe == '30') {
                //     this.hanetimevalue = '最近一个月'
                // } else if(res.data.hangEffe == '7') {
                //     this.hanetimevalue = '最近七天'
                // }

                //  if(res.data.jianEffe == '365') {
                //     this.jiantimevalue = '最近一年'
                // } else if(res.data.jianEffe == '30') {
                //     this.jiantimevalue = '最近一个月'
                // } else if(res.data.jianEffe == '7') {
                //     this.jiantimevalue = '最近七天'
                // }

                if(res.data.newsScope == '0') {
                    this.scopevalue = "全百度"
                } if(res.data.newsScope == '1') {
                    this.scopevalue = "仅限制百度新闻"
                }
            })
            

        },
    }
}
</script>

<style lang="scss" scoped>
.el-input-number {
    width: 217px !important;
}
.textareaUrl {
    margin-top: 10px;
}
.el-dialog__body {
    margin-top: 0;
}
.baidubox {
    margin-bottom: 20px;
}
.penSvn {
    cursor: pointer;
    width: 20px;
    height: 20px;
}
// .bigbox {
//         background-color: #fff;
//         padding: 20px;
//     }
.el-tabs {
    background-color: #fff;
}
.el-tabs__nav-scroll {
    margin-left: 50px;
}
.el-tabs__active-bar {
    width: 86px;
}
    .accounthead {
      background-color: #f9f6f9;
        position: relative;
        text-align: left;
        width: 100%;
        height: 70px;
        font-size: 22px;
        line-height: 86px;
        // border-bottom: 1px solid #ccc;
        span {
            position: absolute;
            bottom: -9px;
            left:0;
            // margin-bottom: 10px;
            // margin-left: 19px;
        }
    }

    .selectBox {
        position: relative;
        background-color: #fff;
        padding-left: 40px;
        padding-bottom: 15px;
        text-align: left;
        .bottomborder {
            cursor: pointer;
            width: 441px;
            height: 30px;
            border: 0;
            outline: none;
            border-bottom: 1px solid #c9c9c9;
            // background-image: url('../../assets/pen.png');
            // background-repeat:  no-repeat;
            line-height: 30px;
            font-size: 20px;
            text-indent: 25px;
        }
    }

    .penico {
        position: absolute;
        top: 47px;
        left: 41px;
    }


        .moudlename {
       text-align: left;
       >div {
          font-size: 20px;
       }
       .moudleinput {
          width: 256px;
          height: 35px;
          font-size: 18px;
       }
    }

    .moudlecon {
       text-align: left;
       .text1 {
          font-size: 16px;
          color: #5D5D5D;
       }
       .text2 {
           margin-top: -30px;
          color: #666666;
          font-size: 13px;
       }
       textarea {
          width:100%;
          height:292px;
       }
    }

    .penurl {
        top: 60px;
    }

    .urlActive {
        font-size: 12px;
        line-height: 1;
        color: #ccc;
    }

</style>

